const { regeneratorRuntime, dayjs } = global

Page(global.connect(
  state => ({
    ...state.activityReducer
  }),
  dispatch => ({
    async asyncAdsPostionSettingSubmit(data) {
      return dispatch(global.activityReducer.asyncAdsPostionSettingSubmit(data))
    },
    async asyncAdsBlockSettingData(data) {
      return dispatch(global.activityReducer.asyncAdsBlockSettingData(data))
    },
  })
)({
  data: {
    count: 1
  },
  onLoad() {
    console.log(this.route)
    this.setData({
      count: Number(this.data.mosStep1.num) || 1
    })
  },
  handleLicon1Tap() {
    wx.navigateBack()
  },
  handleMovCount(e) {
    let { count } = this.data
    count -= 1
    if (count > 0) {
      this.setData({ count })
    }
  },
  handleAddCount(e) {
    let { count } = this.data
    count += 1
    this.setData({ count })
  },
  handleEditBlock(e) {
    console.log('handleEditBlock', e)
    const { index } = e.currentTarget.dataset
    this.asyncAdsBlockSettingData({ index })
    global.handleRoute({ route: 'mos-step2' })
  },
  handleNextStep(e) {
    console.log('handleNextStep', e)
    const { count } = this.data
    this.asyncAdsPostionSettingSubmit({
      num: count
    })
    wx.navigateBack()
  }
}))